package com.ruoyi.qyj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.qyj.domain.TbFilePatrol;
import com.ruoyi.qyj.service.ITbFilePatrolService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 巡检消缺文件管理Controller
 * 
 * @author yellow
 * @date 2023-05-23
 */
@RestController
@RequestMapping("/qyj/patrol")
public class TbFilePatrolController extends BaseController
{
    @Autowired
    private ITbFilePatrolService tbFilePatrolService;

    /**
     * 查询巡检消缺文件管理列表
     */
    @PreAuthorize("@ss.hasPermi('qyj:patrol:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbFilePatrol tbFilePatrol)
    {
        startPage();
        List<TbFilePatrol> list = tbFilePatrolService.selectTbFilePatrolList(tbFilePatrol);
        return getDataTable(list);
    }

    /**
     * 导出巡检消缺文件管理列表
     */
    @PreAuthorize("@ss.hasPermi('qyj:patrol:export')")
    @Log(title = "巡检消缺文件管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbFilePatrol tbFilePatrol)
    {
        List<TbFilePatrol> list = tbFilePatrolService.selectTbFilePatrolList(tbFilePatrol);
        ExcelUtil<TbFilePatrol> util = new ExcelUtil<TbFilePatrol>(TbFilePatrol.class);
        util.exportExcel(response, list, "巡检消缺文件管理数据");
    }

    /**
     * 获取巡检消缺文件管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('qyj:patrol:query')")
    @GetMapping(value = "/{patrolId}")
    public AjaxResult getInfo(@PathVariable("patrolId") Long patrolId)
    {
        return AjaxResult.success(tbFilePatrolService.selectTbFilePatrolByPatrolId(patrolId));
    }

    /**
     * 新增巡检消缺文件管理
     */
    @PreAuthorize("@ss.hasPermi('qyj:patrol:add')")
    @Log(title = "巡检消缺文件管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbFilePatrol tbFilePatrol)
    {
        return toAjax(tbFilePatrolService.insertTbFilePatrol(tbFilePatrol));
    }

    /**
     * 修改巡检消缺文件管理
     */
    @PreAuthorize("@ss.hasPermi('qyj:patrol:edit')")
    @Log(title = "巡检消缺文件管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbFilePatrol tbFilePatrol)
    {
        return toAjax(tbFilePatrolService.updateTbFilePatrol(tbFilePatrol));
    }

    /**
     * 删除巡检消缺文件管理
     */
    @PreAuthorize("@ss.hasPermi('qyj:patrol:remove')")
    @Log(title = "巡检消缺文件管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{patrolIds}")
    public AjaxResult remove(@PathVariable Long[] patrolIds)
    {
        return toAjax(tbFilePatrolService.deleteTbFilePatrolByPatrolIds(patrolIds));
    }
}
